	var domainUrl="";
	$(function(){
		var test = window.location.pathname;
		var sts=test.split("/"); 
		if(sts[1]!='common'){
			domainUrl="/" + sts[1] +"/common/region/queryProvinceRegions";
		}else{
			domainUrl="/common/region/queryProvinceRegions";
		}
		loadProvinceId();
		window.loadProvinceId = loadProvinceId;
	});
	
	function selectProvince(){
		var pid=$("#provinceId").val();
		$("#pid").val('');
		$("#cid").val('');
		$("#aid").val('');
		locadCity(pid);
	}
	function selectCity(){
		var cid=$("#cityId").val();
		$("#cid").val('');
		$("#aid").val('');
		locadArea(cid);
	}
	function loadProvinceId(){	
		var postData="parentRegionId=0";
		if(!$('#provinceId').length)return;
	   // alert(postData);
	    $.ajax({
	        type: "POST",
	        url: domainUrl,
	        data: postData,
	        contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	        async: true, // 同步  true 异步。默认是异步
	        dataType: 'json',
	        error: function(resultdata) {
	        	
	        },
	        success: function(resultdata) {  
	            if(resultdata.returnCode=="0000"){    
	            	 document.getElementById("provinceId").options.length = 0;
	            	 var options = "<option value='0' >选择省</option>";
		                for (var i = 0 ; i < resultdata.data.length; i++ ) {
		                    options += "<option value='" + resultdata.data[i].id+ "'>" +resultdata.data[i].regionName  + "</option>";
		                }
		                $(options).appendTo($("#provinceId"));
		                var pid=$('#pid').val();
		                //alert(pid);
		                if(pid==''){
		                	//没有选择省分
		                	document.getElementById("cityId").options.length = 0;
		                	 var aoptioncs = "<option value='0' >选择市</options>";
				             $(aoptioncs).appendTo($("#cityId"));
				             $("#provinceId").val(0);
				             $("#cityId").val(0);
		                }else{
		                	$("#provinceId").val(pid);
		                	locadCity(pid)
		                }
		                
	            }else{
	            	layer.alert(resultdata.returnMessage);
	            }
	        }
	    });
	}
	function locadCity(pid){
		//alert('locadCity' + pid);	
		var postData="parentRegionId=" + pid;	
	   // alert(postData);
	    $.ajax({
	        type: "POST",
	        url: domainUrl,
	        data: postData,
	        contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	        async: true, // 同步  true 异步。默认是异步
	        dataType: 'json',
	        error: function(resultdata) {
	        	
	        },
	        success: function(resultdata) {  
	            if(resultdata.returnCode=="0000"){    
	            	 document.getElementById("cityId").options.length = 0;
	            	 var options = "<option value='0' >选择市</option>";
		                for (var i = 0 ; i < resultdata.data.length; i++ ) {
		                    options += "<option value='" + resultdata.data[i].id+ "'>" +resultdata.data[i].regionName  + "</option>";
		                }
		                $(options).appendTo($("#cityId"));
		                var cid=$('#cid').val();
		                //alert(cid);
		                if(cid==''){
		                	//没有选择省分
		                	document.getElementById("areaId").options.length = 0;
		                	 var aoptioncs = "<option value='0' >选择县</options>";
				             $(aoptioncs).appendTo($("#areaId"));
				             $("#cityId").val(0);
				             $("#areaId").val(0);
		                }else{
		                	$("#cityId").val(cid);
		                	locadArea(cid)
		                }
		                
	            }else{
	            	layer.alert(resultdata.returnMessage);
	            }
	        }
	    });
	}
	function locadArea(cid){	
		var postData="parentRegionId=" + cid;	
	   // alert(postData);
	    $.ajax({
	        type: "POST",
	        url: domainUrl,
	        data: postData,
	        contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	        async: true, // 同步  true 异步。默认是异步
	        dataType: 'json',
	        error: function(resultdata) {
	        	
	        },
	        success: function(resultdata) {  
	            if(resultdata.returnCode=="0000"){    
	            	 document.getElementById("areaId").options.length = 0;
	            	 var options = "<option value='0' >选择县</option>";
		                for (var i = 0 ; i < resultdata.data.length; i++ ) {
		                    options += "<option value='" + resultdata.data[i].id+ "'>" +resultdata.data[i].regionName  + "</option>";
		                }
		                $(options).appendTo($("#areaId"));
		                var aid=$('#aid').val();
		                //alert(cid);
		                if(aid==''){
		                	//没有选择省分
                            $("#areaId").val(0);
		                }else{
		                	$("#areaId").val(aid);
		                }
		                
	            }else{
	            	layer.alert(resultdata.returnMessage);
	            }
	        }
	    });
	}